/* 
 * File:   StreamedAudioSource.h
 * Author: RedEyedKiller
 *
 * Created on 18 Δεκέμβριος 2010, 9:28 μμ
 */

#ifndef STREAMSOURCE_H
#define	STREAMSOURCE_H

#define AL_LOOP_FOREVER -1

#include "AbstractALSource.h"

namespace al
{

class OGGstream;

class StreamSource : public AbstractALSource
{
    friend class AudioManager;

public:

    /**
     * Sets the timer of this stream back to 0.
     */
    virtual void Rewind();

    /**
     * Prepares this stream source to play the specified file.
     * This method is the core method of this class.
     * @param name
     * @return 
     */
    bool Prepare(const char* filepath);

    /**
     * If needed this stream updates all its buffers.
     * @return 
     */
    bool UpdateStream();

private:
    /**
     * The constructor is private in order to force the creation of new streams 
     * via the AudioManager::CreateStream method.
     * @param source
     */
    StreamSource(ALuint source);
    
    /**
     * The destructor is private in order to force the deletion of streams 
     * via the AudioManager::KillStream method.
     */
    virtual ~StreamSource();

    /**
     * The file stream binded with this stream source.
     */
    OGGstream* dataStream;
    
    /**
     * If false this stream will stop updating.
     */
    bool updatable;
};

};
#endif	/* STREAMESOURCE_H */

